package com.ruoyi.project.cms.knowledgemanagement.service;

import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.project.cms.knowledgemanagement.domain.KnowledgeBenchmarking;
import com.ruoyi.project.cms.knowledgemanagement.mapper.KnowledgeBenchmarkingMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KnowledgeBenchmarkingServiceImpl implements IKnowledgeBenchmarkingService {

    @Autowired
    private KnowledgeBenchmarkingMapper knowledgeBenchmarkingMapper;


    @Override
    public KnowledgeBenchmarking selectOneByID(Long project_id) {
        return knowledgeBenchmarkingMapper.selectOneById(project_id);
    }

    @Override
    public List<KnowledgeBenchmarking> findByName(KnowledgeBenchmarking knowledgeBenchmarking) {
        return knowledgeBenchmarkingMapper.selectByName(knowledgeBenchmarking);
    }

    @Override
    public int removeOneByID(Long project_id) {
        return knowledgeBenchmarkingMapper.deleteOneById(project_id);
    }

    @Override
    public int deleteByIds(Long[] ids) {
        int i = knowledgeBenchmarkingMapper.deleteProjectByIds(ids);
        if(i==ids.length){
            return 1;
        }
        return 0;
    }

    @Override
    public int changeProjectStatus(KnowledgeBenchmarking knowledgeBenchmarking) {

        return  knowledgeBenchmarkingMapper.changeStatus(knowledgeBenchmarking);
    }

    @Override
    public int insertProject(KnowledgeBenchmarking knowledgeBenchmarking) {
        return knowledgeBenchmarkingMapper.insert(knowledgeBenchmarking);
    }

    @Override
    public int updateProject(KnowledgeBenchmarking knowledgeBenchmarking) {
        knowledgeBenchmarking.setUpdateBy(ShiroUtils.getLoginName());
        return knowledgeBenchmarkingMapper.updateOne(knowledgeBenchmarking);
    }


}
